package wxdb.ui;



import javax.swing.*;

import java.awt.*;
import java.awt.event.*;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.util.*;


public class Admin extends JDialog{
	
	private JButton addButton = new JButton("Add");
	private JButton delButton = new JButton("Delete");
	private JButton chpwdButton = new JButton("Change Password");
	private JButton chpriButton = new JButton("Change UserRights ");
	private JButton exitButton = new JButton("Exit ");
	
	private JPanel pane = new JPanel();

	private void setMyPane(){
		GridBagLayout gridbag = new GridBagLayout();
		GridBagConstraints constraints = new GridBagConstraints();
		pane.setLayout(gridbag);
		
		constraints=new GridBagConstraints();
		constraints.fill=GridBagConstraints.HORIZONTAL;
		constraints.insets=new Insets(30,30,30,30);
		constraints.gridwidth=GridBagConstraints.REMAINDER;
		gridbag.setConstraints(addButton, constraints);
		pane.add(addButton);
		
		constraints=new GridBagConstraints();
		constraints.fill=GridBagConstraints.HORIZONTAL;
		constraints.gridwidth=GridBagConstraints.REMAINDER;
		constraints.insets=new Insets(30,30,30,30);
		gridbag.setConstraints(delButton, constraints);
		pane.add(delButton);
		
		constraints=new GridBagConstraints();
		constraints.insets=new Insets(30,30,30,30);
		constraints.fill=GridBagConstraints.HORIZONTAL;
		constraints.gridwidth=GridBagConstraints.REMAINDER;
		gridbag.setConstraints(chpwdButton, constraints);
		pane.add(chpwdButton);
		
		constraints=new GridBagConstraints();
		constraints.insets=new Insets(30,30,30,30);
		constraints.fill=GridBagConstraints.HORIZONTAL;
		constraints.gridwidth=GridBagConstraints.REMAINDER;
		gridbag.setConstraints(chpriButton, constraints);
		pane.add(chpriButton);
		
		constraints=new GridBagConstraints();
		constraints.insets=new Insets(30,30,30,30);
		constraints.fill=GridBagConstraints.HORIZONTAL;
		constraints.gridwidth=GridBagConstraints.REMAINDER;
		gridbag.setConstraints(exitButton, constraints);
		pane.add(exitButton);
		
		setLocation(200,80);
		setContentPane(pane);
	}
	

	private void initListener(){
		ActListener actListener = new ActListener();
		chpwdButton.addActionListener(actListener);
		chpriButton.addActionListener(actListener);
		delButton.addActionListener(actListener);
		addButton.addActionListener(actListener);
		exitButton.addActionListener(actListener);
	}
	
	class ActListener implements ActionListener{
		public void actionPerformed(ActionEvent e){
			if(e.getSource() == chpriButton)
				chpriButtonRun();
			if(e.getSource() == chpwdButton)
				chpwdButtonRun();
			if(e.getSource() == addButton)
				addButtonRun();
			if(e.getSource() == delButton)
				delButtonRun();
			if(e.getSource() == exitButton)
				exitButtonRun();
		}
	}
	
	private void exitButtonRun(){
		System.exit(0);
	}
	
	private void delButtonRun(){
		DelUser du = new DelUser();
	}
	
	private void addButtonRun(){
		AddUser ad = new AddUser();
	}
	
	private void chpwdButtonRun(){
		ChangePasswd cp = new ChangePasswd();
	}
	
	private void chpriButtonRun(){
		ChangeRights cr = new ChangeRights();
	}
	
	public Admin(){
		setTitle("Administrator");
		setSize(400,550);
		initListener();
		setMyPane();
		setVisible(true);
		setResizable(false);
	}
}
